<?php
/**
 * 桥接模式
 * This file is part of pattern.
 * Author: tangzhou
 * Date: 2016/8/29
 * Time: 15:32
 * File: Bridg.php
 */

/**
 * 抽象角色  抽象路
 * Class AbstractRoad
 */
abstract class AbstractRoad
{
    public $icar;
    abstract function run();
}

class SpeedRoad extends AbstractRoad
{
    function Run()
    {
        $this->icar->run();
        echo ":在高速公路上。";
    }
}

class Street extends AbstractRoad
{
    function Run()
    {
        $this->icar->run();
        echo ":在乡村街道上。";
    }
}

/**
 * 抽象角色  抽象车
 * Class AbstractRoad
 */
interface ICar
{
    public function run();
}

class JeepCar implements ICar
{
    public function run()
    {
        echo "jepp";
    }
}

class BMWCar implements ICar
{
    function run()
    {
        echo "BMW";
    }
}

$road = new SpeedRoad();
$road->icar = new BMWCar();
$road->Run();